package com.rd.student.jiaji.class4.suyan.zrrd.day05;

import java.util.Arrays;
import java.util.Random;

public class Demo08 {
    public static void main(String[] args) {
        String[] a={"A","2","3","4","5","6","7","8","9","10","J","Q","K"};
        String[] b={"红桃","梅花","方片","黑桃"};
        String[] card= new String[54];
        int count=0;
        for (int i=0;i<b.length;i++){
            for (int j=0;j<a.length;j++){
                card[count++]=b[i]+a[j];

            }
        }
        card[count++]="小王";
        card[count]="大王";
        System.out.println(Arrays.toString(card));
        //洗牌
        Random ran=new Random();
        for (int i=0;i<card.length;i++){
            int c=ran.nextInt(card.length);
            String temp=card[i];
            card[i]=card[c];
            card[c]=temp;
        }
        System.out.println(Arrays.toString(card));
        //实现发牌  斗地主
        String[] player0= new String[17];
        String[] player1= new String[17];
        String[] player2= new String[17];
        int player0_index=0;
        int player1_index=0;
        int player2_index=0;

        //发牌
        for (int i=0;i<card.length-3;i++){
            if (i%3==0){
                //给0号玩家
               player0[player0_index++]=card[i];
            }
            if (i%3==1){
                //给1号玩家
                player1[player1_index++]=card[i];
            }
            if (i%3==2){
                //给2号玩家
                player2[player2_index++]=card[i];
            }

        }
        String[] cd=new String[3];
        int cd_index=0;
        for (int i=card.length-3;i<card.length;i++){
            card[cd_index]=card[i];
            System.out.println(Arrays.toString(player0));
            System.out.println(Arrays.toString(player1));
            System.out.println(Arrays.toString(player2));
            System.out.println(Arrays.toString(cd));

        }

    }
}
